//
//  NSString+FQDValidation.m
//  FakeQDaily
//
//  Created by mewxiv on 9/10/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "NSString+FQDValidation.h"

@implementation NSString (FQDValidation)

- (BOOL)isValidateEmail
{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [predicate evaluateWithObject:self];
}

- (BOOL)isValidateMobile
{
    NSString *mobileRegex = @"^1[3|4|5|6|7|8|9][0-9]{1}[0-9]{8}$";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", mobileRegex];
    return [predicate evaluateWithObject:self];
}

- (BOOL)isBlankString
{
    NSString *trimmedString = [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    return ([trimmedString length] <= 0);
}

@end
